// 查询应用

import { GetApplicationInfoList } from "@/request/applicationinfo"
import { useEffect, useState } from "react"

export default function useApplication () {
    const [ options, setOptions ] = useState<Array<Record<string,unknown>>>([])
    const getData = async () => {
        const { code, data } = await GetApplicationInfoList({page: 1, limit: 1000} as any)
        if ( code === 200 ) {
            setOptions( data?.list?.map((item: { appName: any; appCode: any })=>{
                return {
                    ...item,
                    label: item.appName,
                    value: item.appCode
                }
            }))
        } else {
            setOptions( [] )
        }
    }
    useEffect( () => {
        getData()
    }, [] )
    return options
}